package charazay.tool.ihm.main;

import java.awt.event.KeyEvent;
import java.util.Locale;
import java.util.ResourceBundle;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;

import charazay.tool.ihm.main.actions.PlayersUpdateAction;
import charazay.tool.ihm.menu.CharazayMenu;
import charazay.tool.ihm.overview.OverviewPanel;
import charazay.tool.misc.Country;
import charazay.tool.misc.Session;
import charazay.tool.managers.files.FileManager;


public class MainWindow extends JFrame {

	private JTabbedPane contentPane;
	public OverviewPanel overview;
	/**
	 * Create the frame.
	 */
	public MainWindow() {
		FileManager.initDirectories();
		Session.initSession();

		Locale currentLocale = new Locale(Session.language, Session.country);
	    ResourceBundle messages = ResourceBundle.getBundle("charazay.tool.locale.Internationalization", currentLocale);
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 950, 600);
		
		CharazayMenu menuBar = new CharazayMenu();
		
		setJMenuBar(menuBar);
		contentPane = new JTabbedPane();
		overview = new OverviewPanel();
		setActionMenu(menuBar);
		
		contentPane.addTab(messages.getString("Overview"), overview);
		contentPane.setMnemonicAt(0, KeyEvent.VK_1);
		setContentPane(contentPane);		
		
	}

	private void setActionMenu(CharazayMenu menuBar) {
		// TODO Auto-generated method stub
		menuBar.players.addActionListener(new PlayersUpdateAction(overview));
	}

}
